import React from "react";
import Child1 from "./child1";
import Child2 from "./child2";

export default class ShareStateParent extends React.Component {
  constructor() {
    super();

    this.state = {
      money: 1,
    };
  }

  parentHandle = (e) => {
    this.setState({ money: e.target.value });
  };

  render() {
    return (
      <>
        <p>状态提升-父亲组件</p>
        <input
          type="text "
          value={this.state.money}
          onChange={this.parentHandle}
        />
        <p></p>
        人民币: <Child1 money={this.state.money}></Child1>
        美--元: <Child2 money={this.state.money}></Child2>
      </>
    );
  }
}
